export function byte_format(size: number): string {
  if (!size) return '-'

  let num = 1024.00 //byte
  if (size < num)
    return size + 'B'
  if (size < Math.pow(num, 2))
    return (size / num).toFixed(2) + 'KB' //kb
  if (size < Math.pow(num, 3))
    return (size / Math.pow(num, 2)).toFixed(2) + 'MB' //M
  if (size < Math.pow(num, 4))
    return (size / Math.pow(num, 3)).toFixed(2) + 'G' //G
  if (size < Math.pow(num, 5))
    return (size / Math.pow(num, 4)).toFixed(2) + 'T' //T

  return (size / Math.pow(num, 5)).toFixed(2) + 'P' //P
}
